﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class productDetail : System.Web.UI.Page
{
    private String bookId;
    BLL.Business.BookBLL bookBLL = new BLL.Business.BookBLL();
    BLL.Business.CommentBLL commBLL = new BLL.Business.CommentBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!object.Equals(Request.QueryString["Book_Idint"], null))
        {
            BindBookInfor();
            BindComment();
        }
    }
    public void BindBookInfor()
    {
        try
        {
            bookId = Request.QueryString["Book_Idint"];
            DataSet ds = new DataSet();
            ds = bookBLL.SelectByBookId(Convert.ToInt32(bookId));

            if ((ds == null) ||
                   (ds.Tables.Count == 0) ||
                   (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0))
            { }
            else
            {
                ds.Tables[0].Columns.Add("sellprice");             // 添加新列（表示订单状态）
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    float Book_Priceflo;
                    float Book_Discountflo;
                    Book_Priceflo = float.Parse(dr["Book_Priceflo"].ToString());
                    Book_Discountflo = float.Parse(dr["Book_Discountflo"].ToString());
                    dr["Book_Coverstr"] = "BackManage/UploadPicture/" + dr[8].ToString();     // 设置路径
                    dr["sellprice"] = Book_Priceflo * Book_Discountflo;                       // 现价
                }
                Repeater1.DataSource = ds.Tables[0].DefaultView;
                Repeater1.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message.ToString() + "')</script>");
        }
    }
    public void BindComment()
    {
        try
        {
            bookId = Request.QueryString["Book_Idint"];
            DataSet ds = new DataSet();
            ds = commBLL.SelectByBookId(Convert.ToInt32(bookId));

            if ((ds == null) ||
                   (ds.Tables.Count == 0) ||
                   (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 0))
            { }
            else
            {
                Repeater2.DataSource = ds.Tables[0].DefaultView;
                Repeater2.DataBind();
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message.ToString() + "')</script>");
        }
    }
}
